package com.ruoyi.wecom.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.wecom.WecomGroupPageQueryDTO;
import com.ruoyi.business.domain.vo.wecom.admin.ChatGroupDetailVO;
import com.ruoyi.business.domain.wecom.TbWecomChatGroup;
import com.ruoyi.business.service.wecom.ITbWecomChatGroupService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@Validated
@Api(value = "企微群列表管理", tags = {"企微群列表管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/wecom/group")
public class WecomGroupController extends BaseController {

    @Resource
    private ITbWecomChatGroupService tbWecomChatGroupService;


    /**
     * 分页查询企微群列表
     */
    @ApiOperation("管理台分页查询企微群列表")
    @SaCheckPermission("wecom:group:page")
    @GetMapping("/sys-page")
    public TableDataInfo<TbWecomChatGroup> sysPage(WecomGroupPageQueryDTO pageQueryDTO, PageQuery pageQuery) {
        return tbWecomChatGroupService.sysPageQuery(pageQueryDTO, pageQuery);
    }

    /**
     * 查询群详情
     */
    @ApiOperation("根据chatId查询客户群详情")
    @GetMapping("sys-detail/{chatId}")
    @SaCheckPermission("wecom:group:detail")
    public R<ChatGroupDetailVO> getInfo(@ApiParam("客户群id")
                                        @NotNull(message = "客户群id不能为空")
                                        @PathVariable("chatId") String chatId) {
        return R.ok(tbWecomChatGroupService.sysSelectDetail(chatId));
    }

}
